Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Respect client's preferred encoding when possible #1

Closed
wants to merge 1 commit into from

Conversation

nthykier
Copy link
Owner

@nthykier nthykier commented Apr 6, 2024

Previously, pygls would always use UTF-16 except when the client tried to hide the fact that it supports UTF-16 (which the LSP spec requires it to do in all cases). Now, pygls will choose the editor's preferred encoding.

When it is UTF-32, pygls saves a bit of computation in most position codec related operations (X_to_client_units + client_num_units are faster, X_from_client_units is about the same), which is great. When it is UTF-16 or UTF-8, the computational load is about the same.

Closes: openlawlibrary#445

Description (e.g. "Related to ...", etc.)

Please replace this description with a concise description of this Pull Request.

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly

@nthykier nthykier force-pushed the fix-445 branch 2 times, most recently from 6870803 to d4395e1 Compare April 6, 2024 12:00
Previously, `pygls` would always use `UTF-16` except when the client
tried to hide the fact that it supports `UTF-16` (which the LSP spec
requires it to do in all cases). Now, `pygls` will choose the editor's
preferred encoding.

When it is `UTF-32`, `pygls` saves a bit of computation in most
position codec related operations (`X_to_client_units` +
`client_num_units` are faster, `X_from_client_units` is about the
same), which is great. When it is `UTF-16` or `UTF-8`, the
computational load is about the same.

Closes: openlawlibrary#445
@nthykier nthykier closed this Apr 6, 2024
@nthykier nthykier deleted the fix-445 branch April 7, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pygls chooses utf-16 encoding when client prefers utf-32 (which would be faster for pygls as well)
1 participant